\ProvidesPackage{gslist}[2000/05/24]

%  \newlist <name of list>%
%           <commands inserted before each item>%
%           <commands inserted between items>%
%           <characters separating items>%
%           <characters terminating the list>%
%           <escape character to suppress insertion
%            of commands before item>
%
%  Example: \newlist\lista{<before>}{<between>}{}{}{}
%           \newlist\listb{<before>}{<between>}{;}{}{}
%           \newlist\listc{<before>}{<between>}{}{.}{}
%           \newlist\listd{<before>}{<between>}{;}{.}{}
%     Each of
%           \lista{abc}
%           \listb{a;b;c}
%           \listc abc.
%           \listd a;b;c.
%     results in
%           <before>{a}<between><before>{b}<between><before>{c}
%
%  Example: \newlist\lista{<before>}{<between>}{}{}{^}
%           \newlist\listb{<before>}{<between>}{;}{}{^}
%           \newlist\listc{<before>}{<between>}{}{.}{^}
%           \newlist\listd{<before>}{<between>}{;}{.}{^}
%     Each of
%           \lista{a^bc}
%           \listb{a;^b;c}
%           \listc a^bc.
%           \listd a;^b;c.
%     results in
%           <before>{a}<between>b<between><before>{c}
%
\newcommand\renewlist[6]{%
  \@ifundefined#1
     {\@latex@error{\noexpand#1undefined}\@ehc}%
     \relax
  \providelist{#1}{#2}{#3}{#4}{#5}{#6}}
\newcommand\newlist[6]{\@ifdefinable#1{\providelist{#1}{#2}{#3}{#4}{#5}{#6}}}
\newcommand\providelist[6]%
   {\def#1##1#5%
       {\def\g@tmpa{##1}%
        \ifx\g@tmpa\empty
           \let\g@tmpa\ignorespaces
        \else
           \def\g@sep{\def\g@sep{#3}}%
           \def\g@tmpa{\@nameuse{\string#1}##1#4\g@nd}%
        \fi
        \g@tmpa
       }%
    \def\g@tmpa{#6}%
    \ifx\g@tmpa\empty
       \@namedef{\string#1}{\@nameuse{\string#1b}}%
    \else
       \@namedef{\string#1}%
          {\@ifnextchar#6{\@nameuse{\string#1a}}{\@nameuse{\string#1b}}}%
       \@namedef{\string#1a}#6##1#4{\g@sep##1\@nameuse{\string#1c}}%
    \fi
    \@namedef{\string#1b}##1#4{\g@sep#2{##1}\@nameuse{\string#1c}}%
    \@namedef{\string#1c}##1\g@nd
       {\def\g@tmpa{##1}%
        \ifx\g@tmpa\empty
           \let\g@tmpa\ignorespaces
        \else
           \def\g@tmpa{\@nameuse{\string#1}##1\g@nd}%
        \fi
        \g@tmpa
       }%
   }

% \add@nd\cmd{arg}
%    expands to
% \cmd arg\@nd
\newcommand\add@nd[2]{#1#2\@nd}

% DEK's list macros (The TeXbook, p. 378)
%
% Test for empty list: \ifx\list\empty ... \else ... \fi
%
\newtoks\g@ta
\newtoks\g@tb
\newif\ifmember

\long\def\leftappenditem#1\to#2%
   {\g@ta={\\{#1}}%
    \g@tb=\expandafter{#2}%
    \edef#2{\the\g@ta\the\g@tb}%
   }
\long\def\rightappenditem#1\to#2%
   {\g@ta={\\{#1}}%
    \g@tb=\expandafter{#2}%
    \edef#2{\the\g@tb\the\g@ta}%
   }
\def\concatenate#1=#2&#3%
   {\g@ta=\expandafter{#2}%
    \g@tb=\expandafter{#3}%
    \edef#1{\the\g@ta\the\g@tb}%
   }
\def\lop#1\to#2%
   {\expandafter\lopoff#1\lopoff#1#2%
   }
\long\def\lopoff\\#1#2\lopoff#3#4%
   {\def#4{#1}%
    \def#3{#2}%
   }
\def\ismember#1\of#2%
   {\memberfalse
    \def\given{#1}%
    \def\\##1{\def\next{##1}\ifx\next\given\membertrue\fi}%
    #2%
   }